(function(){	
	//document.getElementById简化函数
	var _$ = function (id){
		return 'string' == typeof id ? document.getElementById(id) : id;
	};
	
	//页面就绪，允许你绑定一个在DOM文档载入完成后执行的函数
	var domReady = !+'\v1' ? function(f){(function(){
			try{
				document.documentElement.doScroll('left');
			} catch (error){
				setTimeout(arguments.callee, 0);
				return;
			};
			f();
		})();
	} : function(f){
		document.addEventListener('DOMContentLoaded', f, false);
	};


	function getCode(ele) {
		var jsEle,
		ele = ele.previousSibling;	
		while(ele.nodeType !==1){
			ele = ele.previousSibling;
		}

		var getText = function(elems) {
			var ret = "", elem;

			for ( var i = 0; elems[i]; i++ ) {
				elem = elems[i];
				if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
					ret += elem.nodeValue;
				} else if ( elem.nodeType !== 8 ) {
					ret += getText( elem.childNodes );
				};
			};

			return ret;
		};
		

		if(ele.nodeName.toLowerCase() === "pre" || ele.className.indexOf("special") !== -1){
			jsEle=ele.getElementsByTagName("code")[0];
			if(jsEle.className.indexOf("javascript") !==-1){				
				var code = getText([jsEle]);
				return code;
			}
			return false;			
		}
		return false;
	};
	
	//在页面就绪后绑定事件
	domReady(function(){
	
		//--------------------------webAlert演示脚本开始------------------------------//
		
		document.getElementById("mouseEvent2").onclick = document.getElementById("mouseEvent").onclick = function(event){
			event = event || window.event;
			var target = event.target || event.srcElement;
			if(target.nodeName.toLowerCase() === "button"){
				var jsCode = getCode(target);
				if(jsCode){
					new Function(jsCode).call(window);
				}else{
					alert("获取JS代码出错，检查HTML结构")
				}
			}
		}
		
		
	});

})();
